//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "ProcessCathFASTAProfile.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* namefileFASTAProfileIn   = NULL;
  String* namefileFASTAOut         = NULL;
  String* field                    = NULL;

  if (argc < 4) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./OutInfoFromPROFILEInFASTAFormat <Profile FASTA File In> <FASTA File Out> <Kind of INFO (Seq, SS, Conf, Chem, Phys, MT, ChemMT, PhysMT)>" << endl;
    
    return 0;
    
  }
  else {
    
    namefileFASTAProfileIn = new String (argv[1]);
    namefileFASTAOut       = new String (argv[2]);
    field                  = new String (argv[3]);
    
    cout << "---------------------------------------------------------------------------------------------------" << endl;
    cout << "                                        Profile FASTA File In : " << argv[1] << endl;
    cout << "                                               FASTA File Out : " << argv[2] << endl;
    cout << " Kind of INFO (Seq, SS, Conf, Chem, Phys, MT, ChemMT, PhysMT) : " << argv[3] << endl;
    cout << "---------------------------------------------------------------------------------------------------" << endl;
    
  }
  
  ProcessCathFASTAProfile* processCathFASTAProfile = new ProcessCathFASTAProfile ();
  
  cout << "Preparing Files..." << endl;
  processCathFASTAProfile->NamefileIn(namefileFASTAProfileIn);
  processCathFASTAProfile->NamefileOut(namefileFASTAOut);
  
  cout << "Loading Profile FASTA File with Domain Descriptions..." << endl;
  processCathFASTAProfile->LoadData();
  
  cout << "Number of Domains (repeat Seq) : " << processCathFASTAProfile->ListCathDomainProfile()->Length() << endl;

  cout << "Writing the Out File..." << endl;
  
  if      (!strcmp(field->Out(), "Seq"))    processCathFASTAProfile->OutFASTAFileSequence();
  else if (!strcmp(field->Out(), "SS"))     processCathFASTAProfile->OutFASTAFileSecondaryStruture();
  else if (!strcmp(field->Out(), "Conf"))   processCathFASTAProfile->OutFASTAFileConfidenceSeqStr();
  else if (!strcmp(field->Out(), "Chem"))   processCathFASTAProfile->OutFASTAFileChemicalClassification();
  else if (!strcmp(field->Out(), "Phys"))   processCathFASTAProfile->OutFASTAFilePhysicalClassification();
  else if (!strcmp(field->Out(), "MT"))     processCathFASTAProfile->OutFASTAFileMetaStructure();
  else if (!strcmp(field->Out(), "ChemMT")) processCathFASTAProfile->OutFASTAFileEncodeCHAndMTData();
  else if (!strcmp(field->Out(), "PhysMT")) processCathFASTAProfile->OutFASTAFileEncodePHAndMTData();
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (processCathFASTAProfile)   delete processCathFASTAProfile;
  
  if (namefileFASTAProfileIn)    delete namefileFASTAProfileIn;
  if (namefileFASTAOut)          delete namefileFASTAOut;
  if (field)                     delete field;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

